package com.ly.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
@EnableOpenApi // swagger版本2用的 @EnableSwagger2
public class Swagger3Config {

    @Bean
    public Docket defaultApi() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("湘西租车系统")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ly.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        String swaggerUrl = "http://localhost:8090/doc.html";
        return new ApiInfoBuilder()
                .title("湘西租车系统 接口文档")
                .description("湘西租车系统接口文档")
                .termsOfServiceUrl("http://localhost:8090")
                .contact(new Contact("lynn", swaggerUrl, "291221561@qq.com"))
                .license("Apache License Version 2.0")
                .licenseUrl("https://baidu.com")
                .version("1.0.0")
                .build();
    }
}